$(document).ready(function() {

	LTS.colFormatter.moveMode = function(v, row) {
		return moveMode(row);
	}

	LTS.colFormatter.stateFormat = function(v, row) {
		return stateFormat(row);
	}

	LTS.colFormatter.stateFormatJob = function(v, row) {
		return switchStateToCN(row);
	}

	LTS.colFormatter.executeType = function(v, row) {
		return ExecuteType.getTypeStr(parseInt(row['executeType']));
	}

	var synctaskTable = $("#sync-task-table-container").ltsTable({
		url : getUrlBySuffix("/yugong/task/find"),
		templateId : 'sync-task-table'
	});
	synctaskTable.post({}, 1);

	var aynctaskTable = $("#aync-task-table-container").ltsTable({
		url : getUrlBySuffix("/job/find"),
		templateId : 'async-task-table'
	});
	aynctaskTable.post({
		"introduce" : ""
	}, 1);

	// 版本更新
	$(".ibox-title").mouseover(function() {
		$("#newLogs").hide();
		$("#ext-gen1098").show();
	});
	$(".ibox-title").mouseout(function() {
		$("#ext-gen1098").hide();
	})
});
function clickLookIntroduce(ele) {
	$("#welcomeInnerFunctionIntroGenerator-modal").modal("show");
	switch (ele) {
	case 1:
		$("#datasouceManage").show();
		$("#submeterManage").hide();
		$("#gddlManage").hide();
		$("#synchManage").hide();
		$("#asynManage").hide();
		$("#logManage").hide();
		break;
	case 2:
		$("#datasouceManage").hide();
		$("#submeterManage").show();
		$("#gddlManage").hide();
		$("#synchManage").hide();
		$("#asynManage").hide();
		$("#logManage").hide();
		break;
	case 3:
		$("#datasouceManage").hide();
		$("#submeterManage").hide();
		$("#gddlManage").show();
		$("#synchManage").hide();
		$("#asynManage").hide();
		$("#logManage").hide();
		break;
	case 4:
		$("#datasouceManage").hide();
		$("#submeterManage").hide();
		$("#gddlManage").hide();
		$("#synchManage").show();
		$("#asynManage").hide();
		$("#logManage").hide();
		break;
	case 5:
		$("#datasouceManage").hide();
		$("#submeterManage").hide();
		$("#gddlManage").hide();
		$("#synchManage").hide();
		$("#asynManage").show();
		$("#logManage").hide();
		break;
	case 6:
		$("#datasouceManage").hide();
		$("#submeterManage").hide();
		$("#gddlManage").hide();
		$("#synchManage").hide();
		$("#asynManage").hide();
		$("#logManage").show();
		break;
	default:
		break;
	}
}

/**
 * 任务状态
 * 
 * @param row
 */
function stateFormat(row) {
	var state = row['state'];
	if (state == "0") {
		return "未运行";
	}
	return "运行中";
}

/**
 * 运行模式
 * 
 * @param row
 */
function moveMode(row) {

	var moveInt = row['moveMode'];
	var result = "";

	switch (moveInt) {
	case 1:
		result = "MARK";
		break;
	case 2:
		result = "INC";
		break;
	case 3:
		result = "FULL";
		break;
	case 4:
		result = "ALL";
		break;
	case 5:
		result = "CHECK";
		break;
	case 6:
		result = "CLEAR";
		break;
	default:
		result = "未识别";
	}

	return result;

}

/**
 * 根据state值转换成对应的提示信息
 * 
 * @param state
 * @returns {*}
 */
function switchStateToCN(state) {
	var result;
	switch (parseInt(state['state'])) {
	case 0:
		result = "执行成功";
		break;
	case 1:
		result = "提交成功";
		break;
	case 2:
		result = "初始化";
		break;
	case 3:
		result = "运行中";
		break;
	case 4:
		result = "执行失败";
		break;
	case 5:
		result = "被终止";
		break;
	case 6:
		result = "暂停";
		break;
	default:
		result = "状态未知";
		break;
	}
	return result;
}